package com.example.Transaction.controller;
import com.example.comon.domain.R;
import com.example.Transaction.domain.Transaction;
import com.example.Transaction.service.ITransactionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/transaction")
@Api(value = "transaction",tags = "订单管理")
public class TransactionController {

    @Autowired
    private ITransactionService transactionService;
    @GetMapping("/getTransactionList")
    @ApiOperation("获取订单详情")
    public R<List<Transaction>> getTransactionList(Transaction transaction){
        List<Transaction> list =  transactionService.selectTransaction(transaction);
        return R.success(list);
    }
    @PostMapping("/addTransaction")
    @ApiOperation("增加订单")
    public R<Transaction> addTransaction(@RequestBody Transaction transaction){
        transactionService.insertTransaction(transaction);
        return R.success(transaction);
    }
    @PostMapping("/updateTransactionByOrder_id")
    @ApiOperation("修改订单")
    public R updateTransactionByOrder_id(@RequestBody Transaction transaction){
        transactionService.updateTransactionByOrder_id(transaction);
        return R.success();
    }
    @DeleteMapping("/delTransactionByOrder_id")
    @ApiOperation("删除订单")
    public R delTransactionByOrder_id(String order_id){
        transactionService.delTransactionByOrder_id(order_id);
        return R.success();
    }
}
